/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.protocol.passive;

import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanBatteryCurrent;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanBatteryVoltage;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanChargeForbid;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.*;

/**
 * <b>(DianlanChargingBmsInformation)</b>
 * <p>
 * 充电过程 BMS 信息
 * GBT-27930 充电桩与 BMS 充电过程 BMS 信息
 * 帧类型码 0x25(37)
 * 序列号域 0021
 * 数据长度 23(35)
 * 帧校验域 72B9
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/19
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class DianlanChargingBmsInformation {
    /** 交易流水号 */
    @DianlanProtocol(length = 16, start = 0, end = 16, dataType = BCD)
    String                transNo;
    /** 桩编码 */
    @DianlanProtocol(length = 7, start = 16, end = 23, dataType = BCD)
    String                stubNo;
    /** 充电枪号 */
    @DianlanProtocol(length = 1, start = 23, end = 24, dataType = BCD)
    String                chargingPortNo;
    /** BMS 最高单体动力蓄电池电压所在编号 1/位，1 偏移量；数据范围：1~256 */
    @DianlanProtocol(length = 1, start = 24, end = 25, dataType = BIN)
    String                maxSingleBatteryVoltageNo;
    /** BMS 最高动力蓄电池温度 1ºC/位，-50 ºC 偏移量；数据范围：-50 ºC ~+200 ºC */
    @DianlanProtocol(length = 1, start = 25, end = 26, dataType = BIN)
    String                maxBatteryTemperature;
    /** 最高温度检测点编号 1/位，1 偏移量；数据范围：1~128 */
    @DianlanProtocol(length = 1, start = 26, end = 27, dataType = BIN)
    String                maxTemperatureDetectionPointNo;
    /** 最低动力蓄电池温度 1ºC/位，-50 ºC 偏移量；数据范围：-50 ºC ~+200 ºC */
    @DianlanProtocol(length = 1, start = 27, end = 28, dataType = BIN)
    String                miniBatteryTemperature;
    /** 最低温度检测点编号 1/位，1 偏移量；数据范围：1~128 */
    @DianlanProtocol(length = 1, start = 28, end = 29, dataType = BIN)
    String                miniTemperatureDetectionPointNo;
    /**
     * BMS 单体动力蓄电池电压过高/过低
     * <00>：=正常
     * <01>：=过高
     * <10>：=过低
     */
    @DianlanProtocol(length = 2, start = 31, end = 33, dataType = ENUM)
    DianlanBatteryVoltage singleBatteryVoltage;
    /** BMS 整车动力蓄电池荷电状态SOC 过高/过低 */
    @DianlanProtocol(length = 2, start = 33, end = 35, dataType = ENUM)
    DianlanBatteryVoltage vehiclePowerBatteryStatus;
    /** BMS 动力蓄电池充电过电流 */
    @DianlanProtocol(length = 2, start = 37, end = 39, dataType = ENUM)
    DianlanBatteryCurrent powerBatteryOverchargingCurrent;
    /** BMS 动力蓄电池绝缘状态 */
    @DianlanProtocol(length = 2, start = 39, end = 41, dataType = ENUM)
    DianlanBatteryCurrent powerBatteryInsulationStatus;
    /** BMS 动力蓄电池组输出连接器连接状态 */
    @DianlanProtocol(length = 2, start = 41, end = 43, dataType = ENUM)
    DianlanBatteryCurrent powerBatteryOutputConnectorConnectionStatus;
    /** BMS 充电禁止 */
    @DianlanProtocol(length = 2, start = 43, end = 45, dataType = ENUM)
    DianlanChargeForbid   chargeForbid;
    /** 预留位 */
    @DianlanProtocol(length = 2, start = 45, end = 47, dataType = BIN)
    String                reservePlace;
}